package newdecoupling.staffemp.dao.Impl;

import newdecoupling.staffemp.dao.StaffEmpDao;
import newdecoupling.staffemp.pojo.User;
import org.springframework.stereotype.Component;

import java.sql.*;
import java.util.ArrayList;
import java.util.List;


@Component
public class StaffEmpImpl implements StaffEmpDao {


    @Override
    public List<User> findOne() {
//        String url="jdbc:mysql://localhost:3306/wod01";
//        String username = "root";
//        String password = "123456";
//        String sql = "select user,password from staff_user";

        List<User> List = new ArrayList<>();
        return List;
//        Connection connection = null;
//        Statement statement = null;
//        ResultSet resultSet = null;
//        try {
//            Class.forName("com.mysql.jdbc.Driver");
//            connection = DriverManager.getConnection(url, username, password);
//            statement = connection.createStatement();
//            resultSet = statement.executeQuery(sql);
//
//            while (resultSet.next()){
//                User user = new User();
//                user.setUsername(resultSet.getString("user"));
//                user.setPassword(resultSet.getString("password"));
//                List.add(user);
//            }
//            return List;
//        } catch (ClassNotFoundException e) {
//            throw new RuntimeException(e);
//        } catch (SQLException e) {
//            throw new RuntimeException(e);
//        }finally {
//            try {
//                if (resultSet != null) {
//                    resultSet.close();
//                }
//                if (statement != null) {
//                    statement.close();
//                }
//                if (connection != null) {
//                    connection.close();
//                }
//            } catch (SQLException e) {
//                throw new RuntimeException(e);
//            }
//        }


    }
}
